package cn.itcast.ossservice.controller;

import cn.itcast.commonutils.R;
import cn.itcast.ossservice.service.OssService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

@Api(description = "上传管理")
@RestController
@RequestMapping("/eduoss/fileoss")
@CrossOrigin
public class OssController {

    @Autowired
    OssService ossService;

    @ApiOperation(value = "文件(头像)上传")
    @PostMapping("/avatar")
    public R fileUpload(MultipartFile file){

        // 上传文件
        String url = ossService.fileUpload(file);

        return R.ok().data("url",url);
    }
}
